<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="orest.back.userneeds.UserNeedsHandler"%>
<%@page import="net.ssta.core.db.RecordSet"%>
<%@page import="net.ssta.core.db.Record"%>
<%@page import="net.ssta.core.web.HTMLGenerator"%>
<%@page import="orest.front.achieve.AchieveHandler"%>
<%
	String path = request.getContextPath();
    String flag=request.getParameter("flag");
    UserNeedsHandler handler=new UserNeedsHandler();
    Record empty=new Record();
    empty.addData("OPTIONVALUE","");
    empty.addData("OPTIONNAME","请选择");
    empty.addData("PROVINCE_ID","");
    empty.addData("PROVINCE_NAME","请选择");
    RecordSet zdxx= new RecordSet();
    zdxx.add(empty);
    zdxx.add(AchieveHandler.getNewEnergyClassList());
    RecordSet province=handler.getAllProvince();
    province.add(empty);
%>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>


<link type="text/css" rel="stylesheet" href="<%=path %>/includes/css/commonStyle.css"/> 




<script type='text/javascript' src="<%=path %>/includes/js/jquery.js"></script>
<script type="text/javascript" src="<%=path %>/includes/styleBase/js/style.js"></script>
<script type="text/javascript" src="<%=path %>/includes/DatePicker/WdatePicker.js"></script>


<script type="text/javascript" src="<%=path %>/includes/lhgdialog/lhgcore.min.js"></script>
<script type="text/javascript" src="<%=path %>/includes/lhgdialog/lhgdialog.js"></script>

<script type="text/javascript" src="<%=path %>/includes/Fvalidate/Fvalidate.js" ></script>
<link type="text/css" rel="stylesheet" href="<%=path %>/includes/Fvalidate/style.css" />
 
<title>增加前台用户</title>
 
<script type="text/javascript">

var dg = frameElement.dg;

$(document).ready(function()
{
    dg.addBtn( 'save', '保存', save );
	dg.addBtn( 'cancel', '取消', cancel );
	
	if("<%=flag%>"=="true"){
	    alert("新增用户成功!");
	    dg.cancel();
	    dg.win.reloadPage();
	}
	
	$("#search").Fvalidate({live:true});
	
});


function checkForm(){


   if(!$("#search").Fvalidate()){
    return false;
  }
  
 if(re==false){
     alert("用户名已存在，请更换用户名后重试");
     return false;
  }
  
   var v1=$("#pwd1").val();
   var v2=$("#pwd2").val();
   if(v1==""){
      alert("请填写密码！");
      return false;
   }
   if(v1!=v2){
      alert("两次输入的密码不一样！");
      return false;
   }
   document.userFrom.submit();
   return true;
}        
function cancel()
{
  dg.cancel();
}

function save()
{
	checkForm();
}
var re=false;
 function checkUserName(){
 	var v=$("#userName").val();
 	  $.ajax({ 
		type: "POST", url: "<%=path%>/register?method=verifyUserName",
		data:'userName='+v,
		error:function(){alert("与服务器失去联系，请刷新本页面后再重试！");},
		success: function (msg) {
			if("true"==msg){
			   alert("此账号已经被注册过了，请换一个账号进行注册");
			  re=false;
			    
			}else{
				
				 re=true;
			}
		}
	}); 
	}
</script>



<style>
body, html {
	margin:0;
	padding:0;
}
	.ctable{
		font-size:12px;
		cellPadding:0px;
		cellSpacing:0px;
		background-color:#F6F9FF;
		
		} 
 
		.ctable tr{
		height:24px; 
		} 
		.ctable tr td{ 
		border:0px;
		border-top:1px #99bbe8 solid; 
		border-right:1px #99bbe8 solid;
		padding:5px; 
		vertical-align:middle;
		}
</style>
 
</head>
<body>
<form id="search" action="<%=path %>/back/userManager?method=addUser"  name="userFrom" method="post">

<div class="multiEditPanel" style="border:0;padding:10px;width:90%;padding-left:20px;">
  <table cellpadding="0" align="center" cellspacing="0" border="0" class="ctable" style="border-left:1px solid #99bbe8;border-bottom:1px solid #99bbe8;border-right:0px solid red;">
    <tr >
      <td width="30%">用户名：</td>
      <td >
      	<input type="text"  maxlength="20" style="width:120px;" name="user_USERNAME" class="textInput"   id="userName" onblur="checkUserName();"  rule="alphaAndNumber" required label="用户名"/>
      	&nbsp;<font color="red">*</font>
      </td>
     </tr>
     <tr>
      <td>密码：</td>
      <td width="30%" >
		<input type="password"  maxlength="20"  name="user_PWD" style="width:120px;" class="textInput" id="pwd1"/>
	  </td>
    </tr>
    <tr >
      <td>重复密码：</td>
      <td>
	  	<input type="password"  maxlength="20" style="width:120px;" class="textInput" id="pwd2" />
	  </td>
    </tr>
    
     <tr >
      <td>性别：</td>
      <td>
	  	<input type="radio" value="男" name="user_SEX" checked/>男
	  	<input type="radio" value="女" name="user_SEX"/>女
	  </td>
    </tr>
    
    
     <tr >
      <td>真实姓名：</td>
      <td>
	  	<input type="text" name="user_FULLNAME" class="textInput" style="width:120px;"/>
	  </td>
    </tr>
    
        
     <tr >
      <td>Email：</td>
      <td>
	  	<input type="text"  maxlength="20" style="width:120px;" class="textInput" name="user_EMAIL" rule="email"  error="请输入正确的邮箱地址" label="Email" required/>
	   &nbsp;<font color="red">*</font>
	  </td>
    </tr>
    
        
        
     <tr >
      <td>出生年月：</td>
      <td>
	  	<input type="text"  maxlength="20" style="width:120px;" class="textInput" name="user_BIRTHDAY"  readonly  onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" />
	  </td>
    </tr>
    
    
            
 
    
    <tr >
      <td>所在行业：</td>  
      <td>
        <%=HTMLGenerator.getSelectElementHtml("name='user_INDUSTRY' style='width:180px;'",zdxx,"OPTIONVALUE","OPTIONNAME","")%>
	  </td>
    </tr>
    
    
    
     <tr >
      <td>工作单位：</td>
      <td>
	  	<input type="text"  maxlength="20" style="width:180px;" class="textInput"   name="user_WORKORG"/>
	  </td>
    </tr>
    
 
    
    
     <tr >
      <td>电话：</td>
      <td>
	  	<input type="text"  maxlength="20" style="width:180px;" class="textInput"   name="user_TELEPHONE"/>
	  </td>
    </tr>
    
    <tr >
      <td>所在省市：</td>
      <td>
          <%=HTMLGenerator.getSelectElementHtml("name='user_PROVINCE' style='width:180px;'",province,"PROVINCE_ID","PROVINCE_NAME","")%>
   	  </td>
    </tr>
    
     <tr >
      <td>会员类型：</td>
      <td>
	  	<input type="radio" value="0" name="user_MEMBERTYPE" checked/>个人
	  	<input type="radio" value="1" name="user_MEMBERTYPE"/>企业
	  </td>
    </tr>
  </table>
</div>
</form>
</body> 
</html>